<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!doctype html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>LoveTemperature</title>
		<meta name="author" content="ningzero"/>

		<!-- CSS -->
		<link rel="stylesheet" href="css/index.css">
		<!-- end CSS-->

	</head>

	<body>

		<div id="container">
			<header class="header">
				<div id="login_cart_bar">
					<div id="loginRegisterDiv">
						<s:if test="%{#session.user!=null}">
						欢迎惠顾，<s:property value="#session.user.name" />
						<a class="pinkAnchor" href="http://localhost:8080/lovetemperature/sale/logout">退出登录</a>
						</s:if>
						<s:else>
						<a class="pinkAnchor" onclick="showLoginDlg()">登录</a>
						<a class="pinkAnchor" onclick="showRegDlg()">注册</a>
						</s:else>
					</div>
					<div id="cartAccountDiv">
					<s:if test="%{#session.user!=null}">
						<a class="pinkAnchor" onclick="javascript:window.location='http://localhost:8080/lovetemperature/sale/showStepOne'">购物车</a>
						<a class="pinkAnchor" onclick="javascript:window.location='http://localhost:8080/lovetemperature/sale/showMember'">我的账户</a>
					</s:if>
					</div>
				</div>
				<div id="logo_bar">
					<img src="img/logo.gif"/>
					<img id="logo_text" src="img/logo2.png"/>
				</div>
				<div id="nav_bar">
					<ul>
						<li class="nav_padding_left"></li>
						<li class='<s:if test="%{#showCategory=='首页'}">shouye_cur</s:if><s:else>shouye</s:else>'>
							<a href="http://localhost:8080/lovetemperature/index">首页</a>
						</li>
						<li class='<s:if test="%{#showCategory=='蛋糕'}">dangao_cur</s:if><s:else>dangao</s:else>'>
							<a href="http://localhost:8080/lovetemperature/sale/index?category=蛋糕">蛋糕</a>
						</li>
						<li class='<s:if test="%{#showCategory=='面包'}">mianbao_cur</s:if><s:else>mianbao</s:else>'>
							<a href="http://localhost:8080/lovetemperature/sale/index?category=面包">面包</a>
						</li>
						<li class='<s:if test="%{#showCategory=='干点'}">gandian_cur</s:if><s:else>gandian</s:else>'>
							<a href="http://localhost:8080/lovetemperature/sale/index?category=干点">干点</a>
						</li>
						<li class='<s:if test="%{#showCategory=='拌手礼'}">banshouli_cur</s:if><s:else>banshouli</s:else>'>
							<a href="http://localhost:8080/lovetemperature/sale/index?category=拌手礼">伴手礼</a>
						</li>
						<li class='<s:if test="%{#showCategory=='饮品'}">kaquan_cur</s:if><s:else>kaquan</s:else>'>
							<a href="http://localhost:8080/lovetemperature/sale/index?category=饮品">饮品</a>
						</li>
						<li class='<s:if test="%{#showCategory=='其他'}">qita_cur</s:if><s:else>qita</s:else>'>
							<a href="http://localhost:8080/lovetemperature/sale/index?category=其他">其他</a>
						</li>
					</ul>
				</div>
			</header>
			<div id="mainContent" class="mainContent">
				<div id="mainAdvDiv">
					<img src="img/mainAdv.jpg" />
				</div>
				<div id="goodsWrap">
					<div id="underAdvDiv">
						<img src="img/underAdv.gif" />
					</div>
					<div id="underAdvDiv2">
						<img src="img/underAdv2.gif" />
					</div>
					<div id="goodsBar">
						<span id="className"> 商城公告 </span>
					</div>
					<ul id="mallList">
						<li>
							<a href="#" title="【活动】清明伴手礼热卖中，第二件75折"> 【活动】清明伴手礼热卖中，第二件75折 <span class="uptime">2013-03-15</span></a>
						</li>
						<li>
							<a href="#" title="【活动】礼盒买一赠一，蛋糕上海市外环内免费配送"> 【活动】礼盒买一赠一，蛋糕上海市外环内免费配送 <span class="uptime">2013-03-11</span></a>
						</li>
						<li>
							<a href="#" title="【通知】上海克莉丝汀食品有限公司消费卡、券章程（最新）"> 上海克莉丝汀食品有限公司消费卡、券章程（最新） <span class="uptime">2013-03-05</span></a>
						</li>
						<li>
							<a href="#" title="【通知】上海克莉丝汀购卡章程"> 【通知】上海克莉丝汀购卡章程 <span class="uptime">2013-02-20</span></a>
						</li>
						<li>
							<a href="#" title="【活动】礼盒买一赠一，蛋糕上海市外环内免费配送"> 【活动】礼盒买一赠一，蛋糕上海市外环内免费配送 <span class="uptime">2013-03-11</span></a>
						</li>
					</ul>
					
				</div>
				
				<div id="saleGoods">
				</div>
				
			</div>
		</div>
		<!--! end of #container -->
		
		<footer id="footer">
			<img src="img/tmp/tmpfooter.png" />
		</footer>

		<div id="loginDiv" class="dialog">
			<div id="LoginInputDiv">
				<h4>已注册用户，请登录</h4>
				<p>邮箱：<input type="text" id="account"/></p>
				<p>密码：<input type="password" id="password"/></p>
				<div id="loginBtn" class="normalBtn" onclick="login()">登录</div>
			</div>
			<div id="goRegDiv">
				<div class="closeBtnDiv">
					<div class="closeBtn" onclick="closeLoginDlg()">
						X
					</div>
				</div>
				<p>没有帐号？马上<a href="#">注册</a></p>
			</div>
		</div>
		
		<div id="registerDiv" class="dialog">
			<div id="RegInputDiv">
				<h4>用户注册</h4>
				<p>　用户名：<input type="text" id="memberName"/></p>
				<p>　　密码：<input type="password" id="passwordOne" /></p>
				<p>确认密码：<input type="password" id="passwordTwo"/></p>
				<p>电子邮箱：<input type="text" id="memberEmail"/></p>
				<div id="registerBtn" class="normalBtn" onclick="register()">注册</div>
			</div>
			<div id="goLoginDiv">
				<div class="closeBtnDiv">
					<div class="closeBtn" onclick="closeRegDlg()">
						X
					</div>
				</div>
				<p>已有帐号？马上<a href="#">登录</a></p>
			</div>
		</div>
		<!-- scripts -->
		<script type="text/javascript" src="js/libs/jquery-1.9.1.min.js" ></script>
		<script type="text/javascript" src="js/index.js" ></script>
		<script>
		$(function(){
			$('#loginDiv').hide();
			$('#registerDiv').hide();
		});
		function addCur() {
			$('#nav_bar li')
		}
		function login(){
			var account = $('#account').val();
			var password = $('#password').val();
			$.post("http://localhost:8080/lovetemperature/ajax/login",{
				"account":account,
				"password":password
			},function(data){
				alert(data.message);
				if(data.result=='memberSuccess'){
					window.location="http://localhost:8080/lovetemperature/index";
				}else if(data.result=='staffSuccess'){
					window.location="http://localhost:8080/lovetemperature/shop/showOrders";
				}else if(data.result=='adminSuccess'){
					window.location="http://localhost:8080/lovetemperature/sysadmin/showShop";
				}else if(data.result=='managerSuccess'){
					window.location="http://localhost:8080/lovetemperature/manage/memberStat";
				}
				$('#password').val("");
			},"json");
		}
		function register(){
			var name = $('#memberName').val();
			var passwordOne = $('#passwordOne').val();
			var passwordTwo = $('#passwordTwo').val();
			var email = $('#memberEmail').val();
			if(passwordOne != passwordTwo){
				alert("两次输入的密码不一样");
				return;
			}
			$.post("http://localhost:8080/lovetemperature/ajax/register",{
				"member.name":name,
				"member.password":passwordOne,
				"member.email":email
			},function(data){
				alert(data.message);
				if(data.result=='success'){
					location.reload();
				}
				$('#password').val("");
			},"json");
		}
		function addToCart(goodId){
			$.post("http://localhost:8080/lovetemperature/ajax/addToCart",{
				"goodId":goodId
			},function(data){
				alert("添加成功！");
			},"json");
		}
		</script>
		<!-- end scripts-->
	</body>
</html>
